package com.validations;

import java.util.Hashtable;

import com.beans.Person;

public class RegistrationValidations 
{
	Person person;
	private int memberShipNumber;
	private String firstName;
	private String lastName;
	private String address1;
	private String address2;
	private String city;
	private String state;
	private String zipCode;
	private String emailId;
	private String confirmemailId;
	private String password1;
	private String password2;
	private Hashtable<String,String> errors;
	
	public void setMemberShipNumber(int memberShipNumber) {
		this.memberShipNumber = memberShipNumber;
	}
	public int getMemberShipNumber() {
		return memberShipNumber;
	}
	public void setFirstName(String firstName) {
		this.firstName = firstName;
	}
	public String getFirstName() {
		return firstName;
	}
	public void setLastName(String lastName) {
		this.lastName = lastName;
	}
	public String getLastName() {
		return lastName;
	}
	public void setAddress1(String address) {
		this.address1 = address;
	}
	public String getAddress1() {
		return address1;
	}	
	public void setAddress2(String address) {
		this.address2 = address;
	}
	public String getAddress2() {
		return address2;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public String getCity() {
		return city;
	}
	public void setState(String state) {
		this.state = state;
	}
	public String getState() {
		return state;
	}
	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}
	public String getZipCode() {
		return zipCode;
	}
	public void setEmailId(String emailId) {
		this.emailId = emailId;
	}
	public String getEmailId() {
		return emailId;
	}
	public void setConfirmEmailId(String emailId) {
		this.confirmemailId = emailId;
	}
	public String getConfirmEmailId() {
		return confirmemailId;
	}
	public void setPassword1(String password) {
		this.password1 = password;
	}
	public String getPassword1() {
		return password1;
	}
	public void setPassword2(String password) {
		this.password2 = password;
	}
	public String getPassword2() {
		return password2;
	}
	
	public boolean validateForm()
	{
		boolean bool=true;
		if (Validations.validateName(firstName.trim())) 
		{
			errors.put("firstName","Please enter your first name");
			firstName="";
			bool=false;
		}
		if (Validations.validateName(lastName.trim())) 
		{
			errors.put("lastName","Please enter your last name");
			lastName="";
			bool=false;
		}
		if (Validations.validateName(city.trim())) 
		{
			errors.put("city","Please enter the city");
			city="";
			bool=false;
		}
		if (Validations.validateName(state.trim())) 
		{
			errors.put("state","Please enter the state");
			state="";
			bool=false;
		}
		if (Validations.validateEmail(emailId.trim())) 
		{
			errors.put("email","Please enter a valid email address");
			emailId="";
			bool=false;
		}
		if (!emailId.equals("") && (confirmemailId.equals("") || 
				!emailId.equals(confirmemailId))) 
		{
			errors.put("confirmemail","Please confirm your email address");
			confirmemailId="";
			bool=false;
		}
		if (Validations.validatePassword(password1)) 
		{
			errors.put("password1","Please enter a valid password");
			password1="";
			bool=false;
		}
		if (!password1.equals("") && (password2.equals("") || 
		!password1.equals(password2))) 
		{
			errors.put("password2","Please confirm your password");
			password2="";
			bool=false;
		}
		if (Validations.validateZip(zipCode)) 
		{
			errors.put("zipCode","Please enter a valid zip code");
			zipCode="";
			bool=false;
		}
		return bool;
	}

}
